package com.kfm.shop.controller;

import com.alibaba.fastjson.JSON;
import com.kfm.shop.domain.User;
import com.kfm.shop.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/demo1")
    public String demo1() {
        return "demo1";
    }

    @RequestMapping("/demo2")
    public String demo2() {
        return "demo2";
    }

    @RequestMapping("/find/{id}")
    public User findByUid(@PathVariable("id") Integer uid) {
        log.info("接下来要进行{}号用户信息的查询", uid);
        User user = userService.findById(uid);
        log.info("用户信息查询成功,内容为{}", JSON.toJSONString(user));
        return user;
    }


}
